package com.badshun.ojs;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;

public class ScriptLoader {
    private String path;
    private ArrayList<String> scriptContentList;

    public ScriptLoader(String path) {
        this.path = path;

        loadScript();
    }

    private void loadScript() {
        scriptContentList = new ArrayList<String>();

        try {
            BufferedReader bReader = new BufferedReader(new FileReader(new File(path)));
            String temp = "";

            while ((temp = bReader.readLine()) != null) {
                scriptContentList.add(temp);
            }
        } catch (IOException ioe) {
            ioe.printStackTrace();
        }
    }

    public ArrayList<String> getScriptContenList() {
        return scriptContentList;
    }

    // for debug
    public void printContent() {
        for (String content : scriptContentList) {
            System.out.println(content);
        }
    }
}
